package cn.lijiajia3515.cairo.system.modules.dictionary;

import cn.lijiajia3515.cairo.mongo.data.AbstractMongo;
import cn.lijiajia3515.cairo.mongo.data.MetaMongo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.List;

/**
 * 字典 mongo
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)

@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder(toBuilder = true)
public class DictionaryMongo extends MetaMongo {

	/**
	 * id
	 */
	@MongoId
	private ObjectId _id;

	/**
	 * client
	 */
	private String client;

	/**
	 * code 值
	 */
	@org.springframework.data.mongodb.core.mapping.Field
	private String id;

	/**
	 * 名称
	 */
	private String name;

	/**
	 * 字典项
	 */
	private List<Item> items;

	public static final Field FIELD = new Field();

	/**
	 * Dictionary Item
	 */
	@EqualsAndHashCode(callSuper = true)
	@Data
	@Accessors(chain = true)

	/**
	 * 字典项 mongo
	 */
	@NoArgsConstructor
	@AllArgsConstructor
	@SuperBuilder(toBuilder = true)
	public static class Item extends AbstractMongo {
		@MongoId
		private ObjectId _id;

		/**
		 * 标识
		 */
		private String id;

		/**
		 * value
		 */
		private Object value;

		/**
		 * 名称
		 */
		private String name;


	}

	public static class Field extends AbstractMongo.Field {
		public final String CLIENT = field("Client");
		public final String ID = field("Id");
		public final String Name = field("Name");

		public final Items ITEMS = new Items(this, "Items");

		public static class Items extends AbstractMongo.Field {
			public Items() {
			}

			public Items(AbstractMongo.Field parent, String prefix) {
				super(parent, prefix);
			}

			public final String ID = field("Id");
			public final String $ID = field("$.Id");
			public final String VALUE = field("Value");
			public final String $VALUE = field("$.Value");
			public final String NAME = field("Name");
			public final String $NAME = field("$.Name");
		}

	}
}
